home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / mdidem / author.frm (.txt) next >
Encoding:
Visual Basic Form  |  1995-05-02  |  6.3 KB  |  229 lines

  1. VERSION 2.00
  2. Begin Form Authors 
  3.    BackColor       =   &H00C0C0C0&
  4.    Caption         =   "Authors"
  5.    ClientHeight    =   1245
  6.    ClientLeft      =   2790
  7.    ClientTop       =   4080
  8.    ClientWidth     =   3990
  9.    Height          =   1935
  10.    Icon            =   AUTHOR.FRX:0000
  11.    Left            =   2730
  12.    LinkTopic       =   "Form1"
  13.    MDIChild        =   -1  'True
  14.    ScaleHeight     =   1245
  15.    ScaleWidth      =   3990
  16.    Top             =   3450
  17.    Width           =   4110
  18.    Begin TextBox AuthName 
  19.       DataField       =   "Author"
  20.       DataSource      =   "Data1"
  21.       Height          =   285
  22.       Left            =   135
  23.       MaxLength       =   40
  24.       TabIndex        =   0
  25.       Top             =   315
  26.       Width           =   3615
  27.    End
  28.    Begin Data Data1 
  29.       Caption         =   "Data1"
  30.       Connect         =   ""
  31.       DatabaseName    =   ""
  32.       Exclusive       =   0   'False
  33.       Height          =   285
  34.       Left            =   2610
  35.       Options         =   0
  36.       ReadOnly        =   0   'False
  37.       RecordSource    =   "Authors"
  38.       Top             =   720
  39.       Width           =   1140
  40.    End
  41.    Begin Label FormCommand 
  42.       Caption         =   "FormCommand"
  43.       Height          =   240
  44.       Left            =   1440
  45.       TabIndex        =   2
  46.       Top             =   765
  47.       Visible         =   0   'False
  48.       Width           =   1185
  49.    End
  50.    Begin Label Label1 
  51.       BackStyle       =   0  'Transparent
  52.       Caption         =   "Name"
  53.       Height          =   240
  54.       Index           =   0
  55.       Left            =   135
  56.       TabIndex        =   1
  57.       Top             =   135
  58.       Width           =   1005
  59.    End
  60.    Begin Menu FileMenu 
  61.       Caption         =   "&File"
  62.       Begin Menu OpenMenu 
  63.          Caption         =   "&Open"
  64.       End
  65.       Begin Menu SaveMenu 
  66.          Caption         =   "&Save"
  67.       End
  68.       Begin Menu NewMenu 
  69.          Caption         =   "&New"
  70.       End
  71.       Begin Menu CloseMenu 
  72.          Caption         =   "&Close"
  73.       End
  74.       Begin Menu sep 
  75.          Caption         =   "-"
  76.       End
  77.       Begin Menu ExitMenu 
  78.          Caption         =   "E&xit"
  79.       End
  80.    End
  81.    Begin Menu EditMenu 
  82.       Caption         =   "&Edit"
  83.       Begin Menu RestoreMenu 
  84.          Caption         =   "&Restore"
  85.       End
  86.       Begin Menu DeleteMenu 
  87.          Caption         =   "&Delete"
  88.       End
  89.    End
  90.    Begin Menu WindowMenu 
  91.       Caption         =   "&Window"
  92.       WindowList      =   -1  'True
  93.       Begin Menu WindowTileMenu 
  94.          Caption         =   "&Tile"
  95.       End
  96.       Begin Menu WindowCascadeMenu 
  97.          Caption         =   "&Cascade"
  98.       End
  99.       Begin Menu WindowArrangeIconsMenu 
  100.          Caption         =   "&Arrange Icons"
  101.       End
  102.    End
  103. Option Explicit
  104. Option Compare Text
  105. Const RecordType = "Author"
  106. Function CheckData () As Integer
  107. If AuthName = "" Then
  108.     MsgBox "Unableto save record. Author name is blank."
  109.     CheckData = False
  110.     CheckData = True
  111. End If
  112. End Function
  113. Sub CloseMenu_Click ()
  114. Unload Me
  115. End Sub
  116. Sub Data1_Reposition ()
  117. If Data1.EditMode = Data_EditAdd Then
  118.     Caption = "Adding New Author"
  119. ElseIf Data1.Recordset.BOF Or Data1.Recordset.EOF Then
  120.     Caption = "No Author Records Found"
  121.     Caption = "Author #" & Data1.Recordset("AU_ID")
  122. End If
  123. End Sub
  124. Sub Data1_Validate (Action As Integer, Save As Integer)
  125. Select Case Action
  126.     Case Data_ActionDelete
  127.         ' this is due to a delete command
  128.         ' calling routine should confirm deletion
  129.      Case Data_ActionUpdate
  130.         ' make sure data is valid
  131.         If CheckData() Then
  132.             Save = True
  133.         Else
  134.             Action = Data_ActionCancel
  135.             Save = False
  136.         End If
  137.      Case Else
  138.         If Save Then
  139.             ' this is due to an implicit save command
  140.             ' make sure they actually want to save it
  141.             If MainMdi.WindowState = Minimized Then MainMdi.WindowState = Normal
  142.             If Me.WindowState = Minimized Then Me.WindowState = Normal
  143.             Me.Show
  144.             Select Case MsgBox("Do you want to save the changes to this " & RecordType & "?", MB_YesNoCancel)
  145.                 Case IDYes
  146.                     ' they want to save it
  147.                     ' make sure data is valid
  148.                     If Not CheckData() Then
  149.                         Action = Data_ActionCancel
  150.                         Save = False
  151.                     End If
  152.                 Case IDNo
  153.                     Save = False
  154.                 Case Else
  155.                     Save = False
  156.                     Action = Data_ActionCancel
  157.             End Select
  158.         End If
  159. End Select
  160. If Save Then
  161.     On Error GoTo ValidateError
  162.     ' perform the save manually
  163.     Save = False
  164.     Data1.UpdateRecord
  165.     Data1.Recordset.Bookmark = Data1.Recordset.LastModified
  166.     SendAll "Refresh Author"
  167. End If
  168. Exit Sub
  169. ValidateError:
  170.     DataError Err, Error$
  171.     Action = Data_ActionCancel
  172.     Exit Sub
  173. End Sub
  174. Sub DeleteMenu_Click ()
  175. On Error GoTo DeleteError
  176. If MsgBox("Are you sure that you want to delete this " & LCase$(RecordType) & "?", MB_YesNo + MB_DefButton2) = IDYes Then
  177.     Data1.Recordset.Delete
  178.     Data1.Refresh
  179. End If
  180. Exit Sub
  181. DeleteError:
  182.     DataError Err, Error$
  183.     Exit Sub
  184. End Sub
  185. Sub ExitMenu_Click ()
  186. Unload MainMdi
  187. End Sub
  188. Sub Form_Load ()
  189. Height = 1935
  190. Width = 4110
  191. Data1.DatabaseName = gDatabaseName
  192. Data1.Refresh
  193. End Sub
  194. Sub FormCommand_Change ()
  195. Dim Cmd As String, Parameter As String
  196. Dim i As Integer
  197. If FormCommand = "" Then Exit Sub
  198. Cmd = Trim$(FormCommand) & " "
  199. i = InStr(Cmd, " ")
  200. Parameter = Trim$(Mid$(Cmd, i + 1))
  201. Cmd = Left$(Cmd, i - 1)
  202. Select Case Cmd
  203.     Case "FindFirst"
  204.         Data1.Recordset.FindFirst Parameter
  205. End Select
  206. FormCommand = ""
  207. End Sub
  208. Sub NewMenu_Click ()
  209. Data1.Recordset.AddNew
  210. End Sub
  211. Sub OpenMenu_Click ()
  212. OpenDialog.Show 1
  213. End Sub
  214. Sub RestoreMenu_Click ()
  215. Data1.UpdateControls
  216. End Sub
  217. Sub SaveMenu_Click ()
  218. Data1.Recordset.Update
  219. End Sub
  220. Sub WindowArrangeIconsMenu_Click ()
  221. MainMdi.Arrange Arrange_Icons
  222. End Sub
  223. Sub WindowCascadeMenu_Click ()
  224. MainMdi.Arrange Cascade
  225. End Sub
  226. Sub WindowTileMenu_Click ()
  227. MainMdi.Arrange Tile_Horizontal
  228. End Sub
  229.